package com.hj.service.impl;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import com.hj.dao.CompanyInfoMapper;
import com.hj.entity.CompanyInfo;
import com.hj.service.CompanyInfoService;
import com.hj.utils.MultipleDataSource;
import com.hj.vo.Companyview;
@Service("companyinfoservice")
public class CompanyInfoServiceimpl implements CompanyInfoService{
	@Autowired
	private CompanyInfoMapper companyinfomapper;
		
	public List<CompanyInfo> search(CompanyInfo u) {
		MultipleDataSource.setDataSourceKey("dataSource1");
		return companyinfomapper.search(u);
	}

	@Override
	public List<CompanyInfo> selebalance1() {
		MultipleDataSource.setDataSourceKey("dataSource1");
		return companyinfomapper.selebalance1();
	}

	@Override
	public List<CompanyInfo> selebalance2() {
		MultipleDataSource.setDataSourceKey("dataSource1");
		return companyinfomapper.selebalance2();
	}

	@Override
	public List<CompanyInfo> selebalance3() {
		MultipleDataSource.setDataSourceKey("dataSource1");
		return companyinfomapper.selebalance3();
	}

	@Override
	public CompanyInfo searchone(String id) {
		MultipleDataSource.setDataSourceKey("dataSource1");
		return companyinfomapper.searchone(id);
	}

	@Override
	public void change(Companyview uv) {		
		CompanyInfo u=new CompanyInfo();
		u.setCallee_number(uv.getCallee_number());
		u.setContactor(uv.getContactor());
		u.setCompany_name(uv.getCompany_name());
		u.setMobile(uv.getMobile());
		u.setMail(uv.getMail());
		u.setAddress(uv.getAddress());
/*		u.setAgency(uv.getAgency());
		u.setArea(uv.getArea());
		u.setBalance(uv.getBalance());
		u.setCategory(uv.getCategory());
		u.setCharge_cost(uv.getCharge_cost());
		u.setCommission(uv.getCommission());		
		u.setGuide_price(uv.getGuide_price());	
		u.setMemo(uv.getMemo());		
		u.setMonth_base(uv.getMonth_base());
		u.setMonth_fee(uv.getMonth_fee());
		u.setMonth_gift(uv.getMonth_gift());
		u.setMonth_gift_rest(uv.getMonth_gift_rest());
		u.setReal_name(uv.getReal_name());
		u.setSale_manager(uv.getSale_manager());
		u.setSale_mobile(uv.getSale_mobile());
		u.setStatus(uv.getStatus());
		if(uv.getCreate_time()==null){
			
		}else{
			u.setCreate_time(Timestamp.valueOf(uv.getCreate_time()));
		}
		
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy/MM/dd");
		try {
			u.setStart_date(sdf.parse(uv.getStart_date().substring(0,uv.getStart_date().indexOf(" "))));
			u.setExpire_date(sdf.parse(uv.getExpire_date().substring(0,uv.getStart_date().indexOf(" "))));
		} catch (ParseException e) {
			e.printStackTrace();
		}*/
		MultipleDataSource.setDataSourceKey("dataSource1");
		companyinfomapper.change(u);
		
	}
	
}
